import maya.cmds as mc
import motionMacht_facial.mouth_build.motionMacht_mouth_temple
reload(motionMacht_facial.mouth_build.motionMacht_mouth_temple)

import motionMacht_facial.head_stretch_build.head_stretcj_setting
reload(motionMacht_facial.head_stretch_build.head_stretcj_setting)

import LZ_public_command.LZ_UI
reload(LZ_public_command.LZ_UI)

import motionMacht_facial.eyeBrow_build.eyeBrown_builder
reload(motionMacht_facial.eyeBrow_build.eyeBrown_builder)

import motionMacht_facial.nose_build.motionMacht_nose_setting_builde
reload(motionMacht_facial.nose_build.motionMacht_nose_setting_builde)

import motionMacht_facial.eye_setting.motionMacht_createEyeSetting
reload(motionMacht_facial.eye_setting.motionMacht_createEyeSetting)

import motionMacht_facial.singgle_setting_build.motionMacht_singgle_setting_build
reload(motionMacht_facial.singgle_setting_build.motionMacht_singgle_setting_build)


import motionMacht_facial.eyeBrow_build.eyeBrown_builder as eyeBrown_builder
reload(eyeBrown_builder)


class facial_rig_UI(motionMacht_facial.mouth_build.motionMacht_mouth_temple.mouth_temple_build,
                    LZ_public_command.LZ_UI.LZ_UI,
                    motionMacht_facial.head_stretch_build.head_stretcj_setting.head_stretch_setting,
                    motionMacht_facial.eyeBrow_build.eyeBrown_builder.eyeBrwon_builder,
                    motionMacht_facial.nose_build.motionMacht_nose_setting_builde.nose_setting_build,
                    motionMacht_facial.eye_setting.motionMacht_createEyeSetting.createEyeSetting,
                    motionMacht_facial.singgle_setting_build.motionMacht_singgle_setting_build.singgle_setting_build,
                    eyeBrown_builder.eyeBrwon_builder
                    ):
    def __init__(self):
        motionMacht_facial.mouth_build.motionMacht_mouth_temple.mouth_temple_build.__init__(self)
        pass
    def Modular_facial_Win(self):
        mdlar_facial_rig_UI = 'mdlar_facial_rig_UI'
        if mc.window(mdlar_facial_rig_UI,ex = True):
            mc.deleteUI(mdlar_facial_rig_UI)
            
        mc.window(mdlar_facial_rig_UI,widthHeight=(350, 400),t='mdlar_facial_rig_UI',menuBar = True,rtf=True,s=True)
     
        
        
        main = mc.columnLayout('mdlar_facial_Sys_main',columnAttach=('both', 5), rowSpacing=10, columnWidth=350 )
        
        mc.frameLayout( 'loadBaseModel_frameLY',label='Base_Models', borderStyle='in',collapsable=False,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        
        ##
        mc.rowLayout( 'head_model_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'head_model :  ')
        mc.textField( 'head_model_textField',text='' )
        mc.button('load_headModel' ,c = lambda *args:self.loadTextField( 'head_model_textField' ) )
        mc.setParent('loadBaseModel_frameLY')
        
        ##
        mc.rowLayout( 'lips_prefix_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'charator_prefix  :  ')
        mc.textField( 'charator_prefix_textField',text='' )
        mc.setParent('loadBaseModel_frameLY')
       
        mc.separator()
       
       ##
        mc.rowLayout( 'uplip_influnec_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'uplip_TemPositin  :  ')
        mc.textField( 'uplip_influnec_temLoc_textField',text='' )
        mc.button('load_uplips' ,bgc=(0.75,0.75,0.3),c = lambda *args:self.loadTextField( 'uplip_influnec_temLoc_textField' ) )
        mc.setParent('loadBaseModel_frameLY')
        ##
        mc.rowLayout( 'lowlip_influnec_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'lowlip_TemPositin  :  ')
        mc.textField( 'lowlip_influnec_temLoc_textField',text='' )
        mc.button('load_lowlips' ,bgc=(0.75,0.75,0.3),c = lambda *args:self.loadTextField( 'lowlip_influnec_temLoc_textField' ) )
        mc.setParent('loadBaseModel_frameLY')
        ##
        mc.rowLayout( 'conner_influnec_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'conner_TemPositin  :  ')
        mc.textField( 'conner_influnec_temLoc_textField',text='' )
        mc.button('load_conner' ,bgc=(0.75,0.75,0.3),c = lambda *args:self.loadTextField( 'conner_influnec_temLoc_textField' ) )
        mc.setParent('loadBaseModel_frameLY')
        
        '''
        =========================================================
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        
        mc.setParent( main )
        mc.frameLayout( 'motionMatch_setting_frameLY',collapse = 1,label='headStretch_settings', borderStyle='in',collapsable=True,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        mc.separator( style='none' )

        mc.button('import_facial_temple', l='import temples ' , c=  lambda *args:self.importTemples() )
        mc.button('builde_setting ', l=' builde setting ' , c=  lambda *args:self.builde_settings() )
        mc.button('builde_setting ', l=' builde setting ' , c=  lambda *args:self.create_motchMotion_info_bridge() )
        
        
        
        
        mc.showWindow()
    
    
    
    
    
    def importTemples(self):
        
        #self.importStretch_temple()
        eyeBrown_grp = self.createEyeBrownTemple()
        eyeTempleGrp = self.createTemple_eye()
        mouthTemple_grp = self.createTemploc_forUI()
        noseTemple_grp = self.nose_temple()
        cheekGrp = self.createSinggleSetting()
        

        templeGrp = 'facial_temple_grp'
        if mc.objExists(templeGrp) == 0 :
            mc.group( em = True , n = templeGrp )
        mc.parent( eyeBrown_grp , mouthTemple_grp , eyeTempleGrp , noseTemple_grp , cheekGrp ,  templeGrp )

    def builde_settings(self):

        self.createNoseSetting()
        self.createSinggle_setting()
        self.createEyeBrown_setting()
        self.eye_setting_build()

        self.builde_mouth_setting()
        
        #self.create_infoMatch_bridge()
        
        mc.parent( 'lf_eyeBrown_inn_ctrl_driver_bridge','rt_eyeBrown_inn_ctrl_driver_bridge','ac_lf_eye_donottoutch','ac_rt_eye_donottoutch','eye_donottoutch')
        
        donottoutch_grp = 'DO_NOT_TOUCH'
        parentGrp = 'PARENT_GRP'
        
        if mc.objExists(donottoutch_grp) == 0 :
            mc.group(em =True , n = donottoutch_grp )
            
        if mc.objExists(parentGrp) == 0 :
            mc.group(em =True , n = parentGrp )
        #'infoMatch_bridge',
        mc.parent( 'mouth_donottouch','eye_donottoutch' , 'singgle_donottoutch', 'nose_donottoutch', donottoutch_grp )
        mc.parent( 'ac_lf_eye_parentHead','ac_rt_eye_parentHead','eye_parentHead')
        mc.parent(  'singgle_parentHead','mouth_parentHead','eye_parentHead','nose_parentHead', parentGrp )
    
    
    def create_motchMotion_info_bridge(self):
        self.create_infoMatch_bridge()
    '''
    =========================================================
    ||                                                     ||
    ||            singgle                                  ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    

    
    
    '''    
    def createSinggleSetting(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        cheekGrp = 'cheek_temple_grp'
        if mc.objExists( cheekGrp ) == False :
            mc.group( em = True, n= cheekGrp )
        

        mirror_value = 1
        singgle_sp_tem = [ 'ac_lf_squint_temloc', 'ac_lf_cheek_temloc' ]
        for sst in singgle_sp_tem:
            
            self.createSinggleTemple(  prefix = pref , section = sst , ifMirror = mirror_value ,  orgPrefix = 'lf_' , mirrorPrefix = 'rt_' )
            mc.parent( sst , cheekGrp )
            if '_cheek_' in sst:
                mc.setAttr(str(sst)+'.translateX' , 6.738 )
                mc.setAttr(str(sst)+'.translateY' , 174.096 )
                mc.setAttr(str(sst)+'.translateZ' , 6.601 )
                
                if  mirror_value == 1:
                    R_sst = str(sst).replace( 'lf_' , 'rt_')
                    
                    mc.setAttr(str(R_sst)+'.translateX' , -6.738 )
                    mc.setAttr(str(R_sst)+'.translateY' , 174.096 )
                    mc.setAttr(str(R_sst)+'.translateZ' , 6.601 )
                    mc.parent( R_sst , cheekGrp )
                
            if '_squint_' in sst:
                mc.setAttr(str(sst)+'.translateX' , 4.42 )
                mc.setAttr(str(sst)+'.translateY' , 178.3 )
                mc.setAttr(str(sst)+'.translateZ' , 9.368 )
                
                if  mirror_value == 1:
                    R_sst = str(sst).replace( 'lf_' , 'rt_')
                    
                    mc.setAttr(str(R_sst)+'.translateX' , -4.42 )
                    mc.setAttr(str(R_sst)+'.translateY' , 178.3  )
                    mc.setAttr(str(R_sst)+'.translateZ' , 9.368 )
                    mc.parent( R_sst , cheekGrp )
                    
        return cheekGrp
        
    def createSinggle_setting(self):
    
        donottouchGrp = 'singgle_donottoutch'
        parentHead = 'singgle_parentHead'
        
        if mc.objExists(donottouchGrp) == 0:
            mc.group(em=True , n = donottouchGrp )
            
        if mc.objExists(parentHead) == 0:
            mc.group(em=True , n = parentHead )
    
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        IfMirror_value = 2
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        if_BS = 1
        if_jnt = 1
        select_value = 1
        
        #@singgle_infulence_orglist =self.getTextFieldInfo( 'singgle_temLoc_textField' )
        #@singgle_sp_tem = self.seperateList( inputValue = singgle_infulence_orglist)
        
        singgle_sp_tem = ['ac_lf_squint_temloc', 'ac_lf_cheek_temloc']
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(headMesh) == False:
            mc.duplicate(headMesh_org , n = headMesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( headMesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(headMesh) , 1 )
            
        
        if select_value == 1:
            attrUse = ['tx','ty']
        elif  select_value == 2:
            attrUse = ['tx','tz']
        elif  select_value == 3:
            attrUse = ['ty','tz']
        
        
        if IfMirror_value == 1 :
            mirror_value = 0
        else:
            mirror_value = 1
            
        if if_BS == 1 :
            bs_value = 0
        else:
            bs_value = 1
            
        if if_jnt == 1 :
            jnt_value = 0
        else:
            jnt_value = 1
            
            
        
        for sstm in singgle_sp_tem:
            sst = pref + str(sstm)
            if '_squint_' in sst:
                jnt_value = 1
                bs_value = 0
            elif '_cheek_' in sst:
                
                jnt_value = 0
                bs_value = 1
                

            position_tem = mc.xform(sst , q=True, t=True,ws=True)
            ctrlName = str(sst).replace('_temloc', '_ctrl')
            zeroCtrl = self.create_secondry_grp( ctrl_name = ctrlName ,position = position_tem,IfInverse = 0)
            
            mc.parent(zeroCtrl , parentHead )
            self.creatControls_command( type = 14 ,curName= ctrlName ,add=True)
            
            self.createSinggle_SDK_blendshape( inputMesh = headMesh , ifCreateBS = bs_value , ifCC_jnt = jnt_value , ctrl = ctrlName , attr_use = attrUse ,reverse_Z = 0)
            
            
            if mirror_value == 1:
                R_ctrl = str(ctrlName).replace('_lf','_rt')
                zeroCtrl =self.create_secondry_grp( ctrl_name = R_ctrl ,position = ( position_tem[0]*-1 ,position_tem[1],position_tem[2]),IfInverse = 1 )
                mc.parent(zeroCtrl , parentHead )
                self.creatControls_command( type = 14 ,curName= R_ctrl ,add=True)
                self.createSinggle_SDK_blendshape( inputMesh = headMesh , ifCreateBS = bs_value , ifCC_jnt = jnt_value , ctrl = R_ctrl , attr_use = attrUse ,reverse_Z = 1 )
                
        
    def createSinggle_SDK_blendshape(self , inputMesh = '' , ifCreateBS = 1 , ifCC_jnt = 1 , ctrl = 'xxx_bbb01_ctrl' , attr_use = ['tx','ty'] ,reverse_Z = 1 ):
        
        
        
        donottouchGrp = 'singgle_donottoutch'
        parentHead = 'singgle_parentHead'
        
        if mc.objExists(donottouchGrp) == 0:
            mc.group(em=True , n = donottouchGrp )
            
        if mc.objExists(parentHead) == 0:
            mc.group(em=True , n = parentHead )
        
        if ifCreateBS == 1:
            bridge = self.plane_8dir_sdk( driver = ctrl ,firstAttr = attr_use[0] ,secondryAttr = attr_use[1],dircNormalValue = [1,1,1,1] )
            bridgeAttrs = [ 'up_driver' ,'out_driver','dn_driver','inn_driver','upOut_driver','upInn_driver','dnOut_driver','dnInn_driver']
            mc.parent( bridge , donottouchGrp )
            
            Mesh_bs = str(inputMesh) + '_singgleMesh'
            grp_mesh = str(inputMesh) + '_singgleMesh'+'_blendshape'
            
            if mc.objExists(grp_mesh) == 0 :
                mc.group(em= True,n = grp_mesh )
            
            if mc.objExists(Mesh_bs) == False:
                mc.duplicate( inputMesh , n = Mesh_bs )
                mc.parent( Mesh_bs , donottouchGrp )
            for bda  in  bridgeAttrs:
                target_bs = str(ctrl)+'_'+str(bda)
                blend_node = str(Mesh_bs) + '_blendNode'
                if mc.objExists(target_bs) == False:
                    mc.duplicate( inputMesh , n = target_bs )
                    mc.parent( target_bs , grp_mesh )
                self.AppendTarget(  targets = [target_bs] , BlendMesh = Mesh_bs, blendshape_node = blend_node )
                
                driver = str(bridge) + '.' + str( bda )
                driven = str(blend_node) + '.' + str( target_bs )
                self.LZ_serDrivenKey_02( driverAttr = driver , drivenAttr = driven  ,driverV = [0,1] , drivenV = [ 0 , 1 ] ,inType = 'linear' ,outType = 'linear' , preV = 'cycleRelative', poiV = 'cycleRelative')
        if ifCC_jnt ==1:
            jntName = str(ctrl)+'_jnt'
            position = mc.xform(ctrl , q=True,t=True,ws =True)
            rotation_V = mc.xform(ctrl , q=True,ro=True,ws =True)
            
            self.createTransformer( locName = jntName ,position = position ,rotation = rotation_V, type = 'joint',LocPosion = (0,0,0))
            
            mc.parent( jntName , donottouchGrp )
            self.makeZeroGrpTwo( OrgObj = [jntName],sufname='_zero',cenObj='',Mode=0,type = 'group',ro =True)
            mc.connectAttr(str(ctrl)+'.translateX' , str(jntName)+'.translateX')
            mc.connectAttr(str(ctrl)+'.translateY' , str(jntName)+'.translateY')
            #mc.connectAttr(str(ctrl)+'.translateZ' , str(jntName)+'.translateZ')
            
            mc.connectAttr(str(ctrl)+'.rotateX' , str(jntName)+'.rotateX')
            mc.connectAttr(str(ctrl)+'.rotateY' , str(jntName)+'.rotateY')
            mc.connectAttr(str(ctrl)+'.rotateZ' , str(jntName)+'.rotateZ')
            
            if reverse_Z == 0 :
                mc.connectAttr(str(ctrl)+'.translateZ' , str(jntName)+'.translateZ')
                
            else:
                reverseNode = str(jntName)+'_reverse_md'
                mc.createNode('multiplyDivide' , n = reverseNode )

                mc.connectAttr(str(ctrl)+'.translateZ' , str(reverseNode)+'.input1Z')
                
                mc.setAttr(str(reverseNode)+'.input2Z' , -1)
                
                mc.connectAttr(  str(reverseNode)+'.outputZ' , str(jntName)+'.translateZ')
             
            
    '''
    =========================================================
    ||                                                     ||
    ||             mouth                                   ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    
    
    
    '''    
    def createTemploc_forUI(self):
    
        #prefix = mc.textField( 'charator_prefix_textField',q=True,text=True )
        
        mouthTemple = self.create_mouthDefaultTemple()
        
        upLid = ['uplid_temLoc_textField','ac_lf_uplip1_temloc ac_lf_uplip2_temloc ac_rt_uplip1_temloc ac_rt_uplip2_temloc ac_cn_uplip_temloc']
        lowLid = ['lowlid_temLoc_textField','ac_lf_lowlip1_temloc ac_rt_lowlip1_temloc ac_lf_lowlip2_temloc ac_rt_lowlip2_temloc ac_cn_lowlip_temloc']
        L_conner = ['L_conner_temLoc_textField','ac_lf_cornerlip_temloc']
        R_conner = ['R_conner_temLoc_textField','ac_rt_cornerlip_temloc']
        center= ['center_temLoc_textField','ac_cn_mouth_temloc']
        jaw = ['jaw_temLoc_textField','ac_cn_jaw_temloc']
        
        
        pucker = ['pucker_temLoc_textField','ac_cn_pucker_temloc']
        tongue = ['tongue_temLoc_textField','ac_cn_tongue1_temloc ac_cn_tongue2_temloc ac_cn_tongue3_temloc ac_cn_tongue4_temloc']
        tooth = ['tooth_temLoc_textField','ac_cn_lowerteeth_temloc ac_cn_upperteeth_temloc']
        
        return   mouthTemple
    
    def mouth_mirror_temloc(self):
    
        
        textFields = [ 'uplid_temLoc_textField' , 'lowlid_temLoc_textField']
        conner_textFields = [ 'L_conner_temLoc_textField','R_conner_temLoc_textField']
        currentSl = mc.radioButtonGrp( 'mouth_mirrorTempleLoc_RBG',q=True,select = True )
        
        for tf in textFields:
            info_lips = self.getTextInfo(tf)
            mount = len(info_lips)
            info = self.find_max2Min_list(info_lips)
            centerLocInfo = info[(mount-1)/2]
            
            for io_num in range(mount) :
                if currentSl == 1:
                    if info[io_num][1][0] > centerLocInfo[1][0]:
                        
                        mc.xform( info[mount-io_num-1][0] , t = (centerLocInfo[1][0]*2- info[io_num][1][0], info[io_num][1][1],info[io_num][1][2] ),ws=True   )
                        #
                        #
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateX',info[io_num][1][0]*-1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateY',info[io_num][1][1]*1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateZ',info[io_num][1][2]*1)
                else:
                    if info[io_num][1][0] < centerLocInfo[1][0]:
                        mc.xform( info[mount-io_num-1][0] , t = (centerLocInfo[1][0]*2- info[io_num][1][0], info[io_num][1][1],info[io_num][1][2] ) ,ws=True   )
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateX',info[io_num][1][0]*-1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateY',info[io_num][1][1]*1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateZ',info[io_num][1][2]*1)
        
        L_conner = self.getTextInfo(conner_textFields[0])
        R_conner = self.getTextInfo(conner_textFields[1])
        
        info_Lconner = self.find_max2Min_list(L_conner)
        info_Rconner = self.find_max2Min_list(R_conner)

        
        if  currentSl == 1:
        
            mc.xform( R_conner[0], t = (centerLocInfo[1][0]*2- info_Lconner[0][1][0], info_Lconner[0][1][1],info_Lconner[0][1][2] ),ws=True   )
            #mc.setAttr( str(R_conner[0])+'.translateX' ,info_Lconner[0][1][0] *-1 )
            #mc.setAttr( str(R_conner[0])+'.translateY' ,info_Lconner[0][1][1]  )
            #mc.setAttr( str(R_conner[0])+'.translateZ' ,info_Lconner[0][1][2]  )
            
        else:
            mc.xform( L_conner[0], t = (centerLocInfo[1][0]*2- info_Rconner[0][1][0], info_Rconner[0][1][1],info_Rconner[0][1][2] ),ws=True   )
            #mc.setAttr( str(L_conner[0])+'.translateX' ,info_Rconner[0][1][0] *-1 )
            #mc.setAttr( str(L_conner[0])+'.translateY' ,info_Rconner[0][1][1]  )
            #mc.setAttr( str(L_conner[0])+'.translateZ' ,info_Rconner[0][1][2]  )
    
            

    def builde_mouth_setting(self):
    
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(headMesh) == False:
            mc.duplicate(headMesh_org , n = headMesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( headMesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(headMesh) , 1 )
    
        upLid = 'uplid_temLoc_textField'
        lowLid = 'lowlid_temLoc_textField'
        L_con = 'L_conner_temLoc_textField'
        R_con = 'R_conner_temLoc_textField'
        fillCon  = []
        
        centerLoc = 'ac_cn_mouth_temloc'
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        
        mouth_scuplt_split = str(centerLoc).split('_')
        mouth_scuplt_grp = str(centerLoc).replace(mouth_scuplt_split[-1],'scuplt_grp')
        mouth_ctrl_grp = str(centerLoc).replace(mouth_scuplt_split[-1],'ctrl_grp')
        mouth_secjnt_grp = str(centerLoc).replace(mouth_scuplt_split[-1],'secjnt_grp')
        
        if mc.objExists(mouth_scuplt_grp) == 0:
            mc.group(em = True,n = mouth_scuplt_grp)
        else:
            pass
        
        uplid_temloc = 'ac_lf_uplip1_temloc ac_lf_uplip2_temloc ac_rt_uplip1_temloc ac_rt_uplip2_temloc ac_cn_uplip_temloc'
        lowlid_temloc = 'ac_lf_lowlip1_temloc ac_rt_lowlip1_temloc ac_lf_lowlip2_temloc ac_rt_lowlip2_temloc ac_cn_lowlip_temloc'
        L_con_temloc = 'ac_lf_cornerlip_temloc'
        R_con_temloc = 'ac_rt_cornerlip_temloc'
        
        
        for i in [uplid_temloc,lowlid_temloc,L_con_temloc,R_con_temloc]:
            #textFill = mc.textField( i,q=True,text= 1  )
            part_all=[]
            for part in i.split(' '):
                if part !='':
                    part_all.append(part)
            fillCon.append(part_all)

        curves = 'mouth_' + pref +  'lip_deformer'
        uplip_conName = 'ac_cn_' + pref + 'upperlip_con'
        lowlip_conName = 'ac_cn_' + pref + 'lowerlip_con'
        alllip_conName = 'ac_cn_' + pref + 'lip_con'
        offsetGrp = pref +  'ac_cn_jaw_offset'
        
        jaw_tem = 'ac_cn_jaw_temloc'
        
        curveName = self.builde_nurbs(nurbsName = curves , upperLids = fillCon[0] ,lowerLis = fillCon[1],L_conner = fillCon[2][0] ,R_conner = fillCon[3][0] , center = centerLoc ,jaw = jaw_tem ,uplip_con = uplip_conName ,lowlip_con = lowlip_conName ,all_lip_con = alllip_conName ,zerogrp = mouth_ctrl_grp,grp_offset = offsetGrp ,prefix = pref )
        ######################################
        #=====================================
        ##   ---       create secdry joints   ---
        
        uplips_influence_TF = 'uplip_influnec_temLoc_textField'
        lowlips_influence_TF = 'lowlip_influnec_temLoc_textField'
        conner_influence_TF = 'conner_influnec_temLoc_textField'
        influence_all_TF = [uplips_influence_TF,lowlips_influence_TF,conner_influence_TF]
        
        
        influence_uplip = []
        influence_lowlip = []
        influence_conner = []
        influence_all = [influence_uplip,influence_lowlip,influence_conner]
        
        
        
        #self.rivetSecJnt( rivetObjects = uplip_infulence , rivetMesh = curveName ,prefix = 'uplip_mouth_lips') # LZ_general_cammand
        #self.rivetSecJnt( rivetObjects = lowlip_infulence, rivetMesh = curveName ,prefix = 'lowlip_mouth_lips') # LZ_general_cammand
        #self.rivetSecJnt( rivetObjects = center_infulence, rivetMesh = curveName ,prefix = 'center_mouth_lips') # LZ_general_cammand
         
        #----  get information of lips  by textFields  -----
        uplip_infulence_orglist =self.getTextFieldInfo( Field = uplips_influence_TF )
        lowlip_infulence_orglist =self.getTextFieldInfo( Field = lowlips_influence_TF )
        center_infulence_orglist =self.getTextFieldInfo( Field = conner_influence_TF )
        
        uplip_infulence = self.seperateList( inputValue = uplip_infulence_orglist)
        lowlip_infulence = self.seperateList( inputValue = lowlip_infulence_orglist)
        center_infulence = self.seperateList( inputValue = center_infulence_orglist)
        

        
        secjnt_uppref =  pref +  'uplips'
        secjnt_lowpref =  pref +  'lowlips'
        secjnt_connerpref =  pref +  'connerlips'
        
        ###   ==================================================================================================
        parentHead_grp = pref+'mouth_parentHead'
        donottoutch_grp = pref+'mouth_donottouch'
        
        if mc.objExists(parentHead_grp)==0:
            mc.group(em=True ,n = parentHead_grp )
        if mc.objExists(donottoutch_grp)==0:
            mc.group(em=True ,n = donottoutch_grp )
        
        #----  excute the def crateSEcJnt  -----
        
        puckerTem = 'ac_cn_pucker_temloc'
        #tongueTem = 'ac_cn_tongue1_temloc ac_cn_tongue2_temloc ac_cn_tongue3_temloc ac_cn_tongue4_temloc'
        tongue_infulence_orglist = self.getTextInfo('ac_cn_tongue1_temloc ac_cn_tongue2_temloc ac_cn_tongue3_temloc ac_cn_tongue4_temloc')
        tongue_sp_tem = self.seperateList( inputValue = tongue_infulence_orglist)
        
        tooth_infulence_orglist = self.getTextInfo( FieldText = 'ac_cn_lowerteeth_temloc ac_cn_upperteeth_temloc' )
        tooth_sp_tem = self.seperateList( inputValue = tooth_infulence_orglist)
        
        info_secjnt = self.createSecJnt( tooth = tooth_sp_tem , tongue = tongue_sp_tem  , uplips = uplip_infulence ,pucker = puckerTem ,uplipPrifix = secjnt_uppref,lowlips =lowlip_infulence, lowlipPrifix = secjnt_lowpref ,connerlips =center_infulence ,connerPrefix = secjnt_connerpref ,rivetMesh = curveName[0] ,prefix = pref ,sufix = '_secjnt',grp_all= mouth_secjnt_grp ,grp_offset = offsetGrp , followHead =curveName[7],followJaw = curveName[6],mouthZipperAttr = [curveName[8]+'.lf_lip_zipper',curveName[8]+'.rt_lip_zipper'] )
        
        for openjnt_info in info_secjnt[5]:
            openjnt = openjnt_info[0]
            
            ifskin = self.IfSkined(  inputMesh = headMesh_org ) 
            #print(ifskin)

            if ifskin == 0:
                mc.skinCluster( openjnt , headMesh_org ,normalizeWeights = 2 ,toSelectedBones =True )
            else:
                skinNode_headgeo = self.listSkinCluster(inputMesh = headMesh_org)
            
                jntInf = self.listAllSkined_joints( skinClus = skinNode_headgeo )
            
                
                if openjnt not in  jntInf :
                    #print(skinNode_headgeo)
                    
                    mc.skinCluster( skinNode_headgeo , e=True ,ai = openjnt ,lw =True, wt = 0 )
            
        uplip_jnts = []
        lowlip_jnts = []
        connerlip_jnts = []
        
        #uplips_obj = []
        #lowlips_obj = []
        #connerlips_obj = []
        # ---------------------  make orientConstraints for mouth secondry joints  ----------------- 
        #@for uplip in info_secjnt[0]:
        #@    #uplips_obj.append(uplip[0])
        #@    congrp = str(uplip[0])+'_con'
        #@    mc.orientConstraint( curveName[1] , congrp ,mo=True) 
        #@    #mc.connectAttr(str(curveName[1])+'.rotate',str(uplip[0])+'.rotate')
        #@    uplip_jnts.append(uplip[0])
        #@    
        #@for lowlip in info_secjnt[1]:
        #@    #lowlips_obj.append(lowlip[0])
        #@    congrp = str(lowlip[0])+'_con'
        #@    mc.orientConstraint( curveName[2] , congrp ,mo=True) 
        #@    
        #@    #mc.connectAttr(str(curveName[2])+'.rotate',str(lowlip[0])+'.rotate')
        #@    lowlip_jnts.append(lowlip[0])
        #@    
        #@for connerlip in info_secjnt[2]:
        #@    #connerlips_obj.append(connerlip[0])
        #@    congrp = str(connerlip[0])+'_con'
        #@    mc.orientConstraint( curveName[1] ,curveName[2] , congrp ,mo=True) 
        #@    #mc.connectAttr(str(curveName[3])+'.rotate',str(connerlip[0])+'.rotate')
        #@    connerlip_jnts.append(connerlip[0])
        #@    
        #@mc.parent( curveName[4] , info_secjnt[3] , mouth_scuplt_grp )
        #@
        #@if mc.listRelatives(mouth_scuplt_grp,p=True) == None:
        #@    mc.parent( mouth_scuplt_grp , donottoutch_grp)
        #@
        ######################################
        #=====================================
        ##   ---       skinCluster secondryJnts   ---
        
        
        
        #@self.addskinClusters_models( modelHead = headMesh ,jnts = uplip_jnts+ lowlip_jnts + connerlip_jnts ,pref = pref ,sufix = '_Scuplt_mesh')
        
        ######################################
        #=====================================
        ##   ---       createBlendshape   ---
        self.buildBaseBlendShape( headModel = headMesh , prefix = pref ,sufix = '_mouthScuplt_mesh' )
        
        ######################################
        #=====================================
        ##   ---       createBlendshape   ---
        
        
        connerCtrl = [pref+'ac_lf_mouth_ctrl',pref+'ac_rt_mouth_ctrl']
        #L_con = 'L_conner_temLoc_textField'
        #R_con = 'R_conner_temLoc_textField'
        
        
        ######################################
        #=====================================
        ##  -------create mouth conner
        temLoc_conner_L = 'ac_lf_cornerlip_temloc'
        temLoc_conner_R = 'ac_rt_cornerlip_temloc'
        bridgeGrp_mouth = pref+'mouth_bridge_grp'
        
        L_position = mc.xform(temLoc_conner_L,q=True,t=True,ws=True)
        R_position = mc.xform(temLoc_conner_R,q=True,t=True,ws=True)
        
        mouthConnerCtrl = [ (connerCtrl[0],L_position) , (connerCtrl[1],R_position) ] 
        
        self.mouthConner_setting( connerCtrlInfo = mouthConnerCtrl ,prefix = pref )
        
        self.setDrivenKey_forMouthBlendshape(ctrls=connerCtrl , pref = pref , bridgeGrp = bridgeGrp_mouth , poutCtrl = info_secjnt[4]  )
    
    
    
    def linkMouth_2_headStretch(self):
        
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        puckerTem = mc.textField( 'pucker_temLoc_textField' ,q=True,text=True)
        
        jaw_head_stretch = mc.textField( 'link_headStretch_textField',q=True , text=True )
        
        if puckerTem == ' ':
            puckerObj = puckerTem
        else:
            puckerObj = pref + 'ac_cn_pucker_temloc'
        
        splineName = pref+'ac_cn_midheadlowstretch'
        #jawStretch = splineName + '_LZIkSpline_seketon1_jnt'  

        mouth_bridge = pref +   'mouth_bridge_grp'
        
        jaw_loc = pref + 'ac_cn_jaw_temloc'
        
        headStretchBridge = pref + 'ac_cn_midhead_bridge'
        
        self.link_Mouth_2_headStretch( inputReferenceObj = puckerTem , prefix = pref , jaw_stretch = jaw_head_stretch , bridge = mouth_bridge , jawTemloc = jaw_loc , headStretchBridge =  headStretchBridge )
        
        
        mouthParentStretch = pref + 'mouth_paretStretch'
        mc.parent( mouthParentStretch , jaw_head_stretch )
        
    '''
    =========================================================
    ||                                                     ||
    ||             headStretch                             ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    
    
    
    ''' 
    
    def importStretch_temple(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        temple = self.createTemple_stretchHead( prefix = pref )
        
    
    def buildHeadStretch_setting(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        upJntbase = pref+'ac_cn_midhead_temple'
        upJnttip = pref+'ac_cn_upperhead_temple'
        
        lowJntbase = pref+'ac_cn_midheadlow_temple'
        lowJnttip = pref+'ac_cn_lowerhead_temple'
        
        self.createHesdStretch( upper = [upJntbase,upJnttip] ,lower = [ lowJntbase , lowJnttip ] )
    '''
    =========================================================
    ||                                                     ||
    ||             eyeBrow                                 ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    
    
    
    ''' 
    def importEyeBrow_temloc(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        all_locs = self.createTemple( prefix = pref )
        textinput = ''
        for num in range(len(all_locs[1])):
            if num ==0:
                textinput = all_locs[1][num]
                
            else:
                textinput = textinput+ ' '+all_locs[1][num]

        mc.textField( 'eyeBrow_temLoc_textField',e=True , text= textinput )
        
        mc.textField( 'eyeBrow_center_temLoc_textField',e=True, text=all_locs[0])
        
        mc.textField( 'curveReference_textField',e=True, text=all_locs[2])
        
    def mirror_eyeBrow_temloc(self):
        
        textInput = mc.textField( 'eyeBrow_temLoc_textField',q=True,text=True )
        center = mc.textField( 'eyeBrow_center_temLoc_textField',q=True, text=True )
        allInputs = str(textInput).split(' ')
        for ai in allInputs:
            if '' == ai:
                allInputs.remove(ai)

        self.eyeBrow_mirror_temloc( centerLoc = center , TemLocs = allInputs , mirrorDir = 1 )
    
    def build_eyeBrow_setting(self):
        headMesh_org = mc.textField( 'head_model_textField',q=True , text=True )
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(headMesh) == False:
            mc.duplicate(headMesh_org , n = headMesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( headMesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(headMesh) , 1 )
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        curve_reference = mc.textField( 'curveReference_textField' , q=True,text =True )
        
        
        eyeBrowMesh = pref+'eyeBrow_sculpts_mesh'
        mc.duplicate( headMesh , n=eyeBrowMesh)
        inputs = mc.listHistory(headMesh)
        
        blend_node_name = headMesh +'_blendNode'
        
        self.AppendTarget( targets = [eyeBrowMesh] , BlendMesh = headMesh ,blendshape_node = blend_node_name )
        mc.setAttr(str(blend_node_name)+'.' + str(eyeBrowMesh) , 1 )
        
        self.create_eyeBrow_setting( blendMesh = headMesh , inputMesh = eyeBrowMesh ,prefix = pref , temCurve = curve_reference )
        
    '''
    =========================================================
    ||                                                     ||
    ||             nose                                    ||
    ||                                                     ||
    ||                                                     ||
    =========================================================

    '''  
    
    def nose_temple(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        
        headMesh = str(headMesh_org)+'_bridgeMesh'

        noseTempleGrp = self.createNose_temple(  prefix = pref)
        return noseTempleGrp
    def createNoseSetting(self):
        
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        allInputs =[ 'ac_cn_nose_temloc' ,'ac_cn_nosetip_temloc', 'ac_cn_nosebase_temloc', 'ac_lf_nostril_temloc', 'ac_rt_nostril_temloc']
        #noseInput = mc.textField( 'nose_temLoc_textField',q=True , text= True )
        skinMesh = 'mouth_Scuplt_mesh'
        blendMesh = str(headMesh_org )+ '_bridgeMesh'
        

        RivetInputs = ['ac_cn_nose_rivetloc' ,'ac_cn_nosetip_rivetloc' ,'ac_cn_nosebase_rivetloc', 'ac_lf_nostril_rivetloc' ,'ac_rt_nostril_rivetloc' ]


        self.create_nose_setting( noseTemple = allInputs , noseRivet = RivetInputs,skinMesh = skinMesh ,blendshapeMesh = blendMesh)
    
    '''
    =========================================================
    ||                                                     ||
    ||             eye                                     ||
    ||                                                     ||
    ||                                                     ||
    =========================================================

    '''  
    
    def createEyeAimCtrl(self):
    
        org_pre = mc.textField( 'eye_Org_text_textField',q=True , text = True )
        tar_pre = mc.textField( 'eye_replace_textField' , q=True , text = True )
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        lfEye = mc.textField( 'eye_conter_textField',q=True ,text=True )
        value = mc.floatField( 'eye_aimValue_floatField', q=True , value = True )
        
        rtEye = str(lfEye).replace( org_pre , tar_pre )
        
        self.create_aimsetting( prefix = pref , lfEyeTem = lfEye ,rtEyeTem = rtEye ,if_lf = 1 , if_rt = 1  , valueAim = value )
    
        #self.create_aimsetting( prefix = '' , lfEyeTem = 'ac_lf_eye_temloc' ,rtEyeTem = 'ac_rt_eye_temloc' ,if_lf = 1 , if_rt = 1 )

    
    def createTemple_eye(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        #IfMirror = mc.checkBox( 'eye_mirror',q = True , value =True  )

        
        info_eyeTemple = self.createEyeTemple( prefix = pref ,ifMirror = 1 )
        
        return info_eyeTemple
    
    def mdlar_eye_mirror(self):
        
        ['ac_lf_innerlid_temloc','ac_lf_upperlid1_temloc','ac_lf_upperlid2_temloc','ac_lf_upperlid3_temloc','ac_lf_outerlid_temloc','ac_lf_lowerlid3_temloc','ac_lf_lowerlid2_temloc',
            'ac_lf_lowerlid1_temloc','ac_lf_eyecrunch_temloc','ac_lf_innersocket_temloc','ac_lf_uppersocket1_temloc','ac_lf_uppersocket2_temloc','ac_lf_uppersocket3_temloc','ac_lf_outersocket_temloc','ac_lf_lowersocket3_temloc',
            'ac_lf_lowersocket2_temloc','ac_lf_lowersocket1_temloc','ac_lf_eye_temloc']
            
        org_pre = mc.textField( 'eye_Org_text_textField',q=True , text = True )
        tar_pre = mc.textField( 'eye_replace_textField' , q=True , text = True )
        
        mirror_section = mc.radioButtonGrp( 'eye_mirrorTempleLoc_RBG',q=True, sl =True )
        
        socket = mc.textField( 'eye_socket_temLoc_textField', q=True , text = True )
        upperlid = mc.textField( 'eye_upperlid_temLoc_textField', q=True , text = True )
        lowerlid = mc.textField( 'eye_lowerlid_textField', q=True , text = True )
        inn_conner = mc.textField( 'inn_eye_conner_textField', q=True , text = True  )
        outconner = mc.textField( 'out_eye_conner_textField', q=True , text = True  )
        eyeBallcentoer = mc.textField( 'eye_conter_textField', q=True , text = True )
        crunch = mc.textField( 'eye_eyecrunch_textField', q=True , text = True )
        
        eye_socket_all = str(socket).split(' ')
        for ai in eye_socket_all:
            if '' == ai:
                eye_socket_all.remove(ai)
                
        upperlid_all = str(upperlid).split(' ')
        for ai in upperlid_all:
            if '' == ai:
                upperlid_all.remove(ai)
                
        lowerlid_all = str(lowerlid).split(' ')
        for ai in lowerlid_all:
            if '' == ai:
                lowerlid_all.remove(ai)
        
        allloc = eye_socket_all + upperlid_all + lowerlid_all +[inn_conner] +[outconner] +[eyeBallcentoer] + [crunch]
        #print(mirror_section)
        self.eye_mirrorLocator( mirrorSection = mirror_section ,centorLoc = '' , orgPre = org_pre , tarPre = tar_pre , inputLoctors = allloc )
    
    
    
    
    
    
    
    def eye_setting_build(self):
    
        headMesh_org = mc.textField( 'head_model_textField',q=True,text= True )
        head_mesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(head_mesh) == False:
            mc.duplicate(headMesh_org , n = head_mesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( head_mesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(head_mesh) , 1 )
        
        #IfMirror = mc.checkBox( 'eye_mirror',q = True , value = True  )
        
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        #@eye_socket = mc.textField( 'eye_socket_temLoc_textField',q=True,text = True )
        upperlid =  pref + 'ac_lf_upperlid2_temloc'
        lowerlid =  pref + 'ac_lf_lowerlid2_temloc'
        #@inn_conner = mc.textField( 'inn_eye_conner_textField',q=True,text = True )
        #@out_conner = mc.textField( 'out_eye_conner_textField',q=True,text = True )
        eye_center = pref + 'ac_lf_eye_temloc'
        
        
        #@local_setting = mc.radioButtonGrp( 'eye_setting_RBG',q=True,sl=True  )
        local_setting = 3
        #@orgFix = mc.textField( 'eye_Org_text_textField',q=True , text=True )


        #@replaceFix = mc.textField( 'eye_replace_textField',q=True,text=True )
        
        #@eyecrunch_lf = mc.textField( 'eye_eyecrunch_textField',q=True,text=True)
        
        
        ##---------------------------------------------------------
        
        parentHeadGrp = pref +  'eye_parentHead'
        donottoutchGrp = pref + 'eye_donottoutch'
        parentStretchGrp = pref +  'eye_parentStretch'
        
        if mc.objExists( parentHeadGrp ) == 0:
            mc.group(em=True, n = parentHeadGrp )
        
        if mc.objExists( donottoutchGrp ) == 0:
            mc.group(em=True, n = donottoutchGrp )
            
        if mc.objExists( parentStretchGrp ) == 0:
            mc.group(em=True, n = parentStretchGrp )
            
            
            
            
        #
        #---------------------------------------------------------

        #@eye_socket_all = str(eye_socket).split(' ')
        #@for ai in eye_socket_all:
        #@    if '' == ai:
        #@        eye_socket_all.remove(ai)
        #@        
        #@upperlid_all = str(upperlid).split(' ')
        #@for ai in upperlid_all:
        #@    if '' == ai:
        #@        upperlid_all.remove(ai)
        #@        
        #@lowerlid_all = str(lowerlid).split(' ')
        #@for ai in lowerlid_all:
        #@    if '' == ai:
        #@        lowerlid_all.remove(ai)
        #@        
        ##---------------------------
        #@eye_socket_rt = str(eye_socket).replace( orgFix , replaceFix )
        #@upperlid_rt = str(upperlid).replace( orgFix , replaceFix )
        #@lowerlid_rt = str(lowerlid).replace( orgFix , replaceFix )
        #@inn_conner_rt = str(inn_conner).replace( orgFix , replaceFix )
        #@out_conner_rt = str(out_conner).replace( orgFix , replaceFix )
        #@eye_center_rt = str(eye_center).replace( orgFix , replaceFix )
        #@
        
        #@eye_socket_all_rt = str(eye_socket_rt).split(' ')
        #@for ai in eye_socket_all_rt:
        #@    if '' == ai:
        #@        eye_socket_all_rt.remove(ai)
        #@        
        #@upperlid_all_rt = str(upperlid_rt).split(' ')
        #@for ai in upperlid_all_rt:
        #@    if '' == ai:
        #@        upperlid_all_rt.remove(ai)
        #@        
        #@lowerlid_all_rt = str(lowerlid_rt).split(' ')
        #@for ai in lowerlid_all_rt:
        #@    if '' == ai:
        #@        lowerlid_all_rt.remove(ai)
        #@
        #----------------------------
        eyectrl_lf = pref + 'ac_lf_eye_ctrl'
        uplidctrl_lf = pref + 'ac_lf_upperlid_ctrl'
        lowerlidectrl_lf = pref + 'ac_lf_lowerlid_ctrl'
        eyeballctrl_lf = pref + 'ac_lf_eyeball_ctrl'
        #@
        eyectrl_rt = pref + 'ac_rt_eye_ctrl'
        uplidctrl_rt = pref + 'ac_rt_upperlid_ctrl'
        lowerlidectrl_rt = pref + 'ac_rt_lowerlid_ctrl'
        eyeballctrl_rt = pref + 'ac_rt_eyeball_ctrl'
        #@
        #@eyecrunch_rt = str(eyecrunch_lf).replace(orgFix , replaceFix)
        #@#----------------------------
        #@if local_setting == 1 or local_setting == 3 :
        #@    info_eye_lf = self.create_eye_settings( ifMirror = 0 , prefix = pref , uplidTem = upperlid_all ,lowerlidTem = lowerlid_all, socketTem = eye_socket_all ,inn_conner = inn_conner,out_conner = out_conner ,eye_center = eye_center, eyectrl = eyectrl_lf,uplidctrl = uplidctrl_lf ,lowerlidectrl = lowerlidectrl_lf ,eyeballctrl = eyeballctrl_lf , eyecrunch = eyecrunch_lf )
        #@    #print(upperlid_all)
        #@    mc.parent(info_eye_lf[3][0] , parentHeadGrp )
        #@    mc.parent(info_eye_lf[3][1] , donottoutchGrp )
        #@    mc.parent(info_eye_lf[3][2] , parentStretchGrp )
        #@    
        #@if local_setting == 2 or local_setting == 3:
        #@    info_eye_rt = self.create_eye_settings( ifMirror = 1 , prefix = pref , uplidTem = upperlid_all_rt ,lowerlidTem = lowerlid_all_rt, socketTem = eye_socket_all_rt ,inn_conner = inn_conner_rt,out_conner = out_conner_rt ,eye_center = eye_center_rt , eyectrl = eyectrl_rt,uplidctrl = uplidctrl_rt ,lowerlidectrl = lowerlidectrl_rt ,eyeballctrl = eyeballctrl_rt , eyecrunch = eyecrunch_rt )
        #@    #print(upperlid_all_rt)
        #@    mc.parent(info_eye_rt[3][0] , parentHeadGrp )
        #@    mc.parent(info_eye_rt[3][1] , donottoutchGrp )
        #@    mc.parent(info_eye_rt[3][2] , parentStretchGrp )
        #@
        
        upperlid =  pref + 'ac_lf_upperlid2_temloc'
        lowerlid =  pref + 'ac_lf_lowerlid2_temloc'
        eye_center = pref + 'ac_lf_eye_temloc'
        
        upperlid_rt =  pref + 'ac_rt_upperlid2_temloc'
        lowerlid_rt =  pref + 'ac_rt_lowerlid2_temloc'
        eye_center_rt = pref + 'ac_rt_eye_temloc'
        
        
        info_eye_lf = self.create_eye_settings( ifMirror = 0 , prefix = pref , uplidTem = upperlid ,lowerlidTem = lowerlid , socketTem = '' ,inn_conner = '',out_conner = '' ,eye_center = eye_center, eyectrl = eyectrl_lf,uplidctrl = uplidctrl_lf ,lowerlidectrl = lowerlidectrl_lf ,eyeballctrl = eyeballctrl_lf  )
        info_eye_rt = self.create_eye_settings( ifMirror = 1 , prefix = pref , uplidTem = upperlid_rt ,lowerlidTem = lowerlid_rt , socketTem = '' ,inn_conner = '',out_conner = '' ,eye_center = eye_center_rt, eyectrl = eyectrl_rt,uplidctrl = uplidctrl_rt ,lowerlidectrl = lowerlidectrl_rt,eyeballctrl = eyeballctrl_rt )
        #
        #=====================================================================
        #-----------  link eye connections -------------------------------
        

        #pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        #local_setting = mc.radioButtonGrp( 'eye_setting_RBG',q=True,sl=True  )
        
        uplidAttr_lf = pref + 'ac_lf_upperlid_ctrl.translateY'
        lowlidAttr_lf = pref + 'ac_lf_lowerlid_ctrl.translateY'
        crunchAttr_lf =  pref + 'ac_lf_eyecrunch_ctrl.translateY'
        
        uplidAttr_rt = str(uplidAttr_lf).replace('lf_','rt_')
        lowlidAttr_rt = str(lowlidAttr_lf).replace('lf_','rt_')
        crunchAttr_rt = str(crunchAttr_lf).replace('lf_','rt_')
        
        
        
        
            
            
        
        if local_setting == 1 or local_setting == 3:
        
            uplid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = uplidAttr_lf ,inverse = 0 )
            lowerlid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = lowlidAttr_lf ,inverse = 1 )
            
            bridge_info_lf = self.createEye_crunchExpand_network( crunchCtrlAttr = crunchAttr_lf , upperlid_ctrlAttr = uplid_eyeAttrs[0] , lowerlid_ctrlAttr = lowerlid_eyeAttrs[0] ,narmalValue = 1  )
            
            
            self.setDrivenFrame(  bridge = bridge_info_lf[0] , offsetGrp = [ info_eye_lf[0][0] , info_eye_lf[0][1] ] )
            
            mc.parent( uplid_eyeAttrs[1] , info_eye_lf[3][1] )
            mc.parent( lowerlid_eyeAttrs[1] , info_eye_lf[3][1] )

                
            
        if local_setting == 2 or local_setting == 3:
            uplid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = uplidAttr_rt ,inverse = 0 )
            lowerlid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = lowlidAttr_rt ,inverse = 1 )
            
            bridge_info_rt = self.createEye_crunchExpand_network( crunchCtrlAttr = crunchAttr_rt , upperlid_ctrlAttr = uplid_eyeAttrs[0] , lowerlid_ctrlAttr = lowerlid_eyeAttrs[0] ,narmalValue = 1  )
            
            
            self.setDrivenFrame(  bridge = bridge_info_rt[0] , offsetGrp = [ info_eye_rt[0][0] , info_eye_rt[0][1] ] )
            
            mc.parent( uplid_eyeAttrs[1] , info_eye_rt[3][1] )
            mc.parent( lowerlid_eyeAttrs[1] , info_eye_rt[3][1] )
            
            
        #=====================================================================================
        #-------------------------------  set driven keyFrame  -------------------------------
            
        #self.LZ_setDrivenKey( driverAttr = bridge_info_lf[0] ,drivenAttr = str(info_eye_lf[0][0]) + '' , 0, 0 )
            if local_setting == 1 or local_setting == 3:
                self.setDrivenFrame(  bridge = bridge_info_lf[0] , offsetGrp = [ info_eye_lf[0][0] , info_eye_lf[0][1] ] )
                mc.parent( bridge_info_lf[0] ,  donottoutchGrp )
            if local_setting == 2 or local_setting == 3:
                self.setDrivenFrame(  bridge = bridge_info_rt[0] , offsetGrp = [ info_eye_rt[0][0] , info_eye_rt[0][1] ] )
                mc.parent(  bridge_info_rt[0]  , donottoutchGrp )
            
            

        #=====================================================================================
        #-------------------------------  skinCluster add  -------------------------------
        
        eyeBaseJnt = pref + 'eye_basejnt'
        
        
        
        if mc.objExists(eyeBaseJnt) == 0:
            self.createTransformer( locName = eyeBaseJnt ,position = ( 0,0,0) , rotation = ( 0,0,0) ,type = 'joint',LocPosion = (0,0,0))
            mc.parent(eyeBaseJnt , donottoutchGrp )
        
        
        
        if  local_setting == 1:
            eyejnts = info_eye_lf[1]+[eyeBaseJnt]
            follow_joints = info_eye_lf[5]
        
        if  local_setting == 2:
            eyejnts = info_eye_rt[1]+[eyeBaseJnt]
            follow_joints = info_eye_rt[5]
        if  local_setting == 3:
            eyejnts = info_eye_lf[1] + info_eye_rt[1] + [eyeBaseJnt]
            follow_joints = info_eye_lf[5] +info_eye_rt[5] 
            
        #info_eye_lf[1]
        
        self.skinCluster_add_2_eyeGeo(  headGeo = headMesh_org , skingeo = head_mesh  ,eyeOpenCloseJnts = eyejnts , followJnts = follow_joints )

        #=====================================================================================
        #-------------------------------  wireDeformer add  -------------------------------
        #@wireMesh = str(head_mesh) + '_eyeScuplt_mesh'
        #@if mc.objExists(wireMesh) == 0:
        #@    mc.duplicate( head_mesh , n = wireMesh )
        #@    mc.parent( wireMesh , donottoutchGrp )
        #@    
        #@
        #@if  local_setting == 1 or local_setting == 3:
        #@    for curves in info_eye_lf[2]  or local_setting == 3: 
        #@    
        #@        node = pref + 'lf_eye_wire_node'
        #@    
        #@        self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )
        #@
        #@if  local_setting == 2  or local_setting == 3:
        #@
        #@    for curves in info_eye_rt[2] : 
        #@    
        #@        node = pref + 'rt_eye_wire_node'
        #@    
        #@        self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )
        #@        
        #if  local_setting == 3:
        #        
        #    for curves in info_eye_lf[2] : 
        #    
        #        node = pref + 'lf_eye_wire_node'
        #    
        #        self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )
        #        
        #    for curves in info_eye_rt[2] : 
        #    
        #        node = pref + 'rt_eye_wire_node'
        #    
        #        self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )    
        #
        blend_node_name = head_mesh +'_blendNode'
        #@self.AppendTarget( targets = [wireMesh] , BlendMesh = head_mesh ,blendshape_node = blend_node_name )
        #@mc.setAttr(str(blend_node_name)+'.'+wireMesh , 1)
        
        #@parent_grp = mc.listRelatives( wireMesh , p=True)
        #@if parent_grp == None:
        #@    mc.parent( wireMesh , donottoutchGrp )
        
        #=====================================================================================
        #-------------------------------  blendShape add  -------------------------------
        #orgFix , replaceFix
        if local_setting == 1 or  local_setting == 3:
            #lfBridge = bridge_info_lf
            self.eye_blendShape_settings( inputMesh = head_mesh , locPre = 'lf_', prefix = pref , bridge = bridge_info_lf[0] , open_uplid_Attr = 'upperlid_open' , close_uplid_Attr = 'upperlid_close', open_lowerlid_Attr = 'lowerlid_open' , close_lowerlid_Attr = 'lowerlid_close' )
            
        if local_setting == 2 or  local_setting == 3:
            
            self.eye_blendShape_settings( inputMesh = head_mesh , locPre = 'rt_', prefix = pref , bridge = bridge_info_rt[0] , open_uplid_Attr = 'upperlid_open' , close_uplid_Attr = 'upperlid_close', open_lowerlid_Attr = 'lowerlid_open' , close_lowerlid_Attr = 'lowerlid_close')
        
        
        ##====
        
    def create_infoMatch_bridge(self):
        
        infoMatch_bridge = 'infoMatch_bridge'
        infoMatch_value_bridge = 'infoMatch_value_bridge'
        
        if mc.objExists(infoMatch_bridge) == 0:
            mc.group( em=True , n =infoMatch_bridge )
            
        for attr in ['tx','ty','tz','rx','ry','rz','sx','sy','sz','v']:
        
            mc.setAttr( str(infoMatch_bridge) +'.' + str(attr) , lock = True )
            mc.setAttr( str(infoMatch_bridge) +'.' + str(attr) , k = False )
        
        
        
        if mc.objExists(infoMatch_value_bridge) == 0:
            mc.group( em=True , n =infoMatch_value_bridge )
            
        for attr in ['tx','ty','tz','rx','ry','rz','sx','sy','sz','v']:
        
            mc.setAttr( str(infoMatch_value_bridge) +'.' + str(attr) , lock = True )
            mc.setAttr( str(infoMatch_value_bridge) +'.' + str(attr) , k = False )

        
        ###--------  add attributes on the bridge  ----------------------------
        
        matchMotion = [ "CheekSquint_R"
                        ,"EyeBlink_L"
                        ,"EyeBlink_R" 
                        ,"EyeSquint_L" 
                        ,"EyeSquint_R"
                        ,"EyeDown_L" 
                        ,"EyeDown_R" 
                        ,"EyeIn_L" 
                        ,"EyeIn_R" 
                        ,"EyeOpen_L" 
                        ,"EyeOpen_R" 
                        ,"EyeOut_L"
                        ,"EyeOut_R" 
                        ,"EyeUp_L" 
                        ,"EyeUp_R" 
                        ,"BrowsD_L" 
                        ,"BrowsD_R"
                        ,"BrowsU_C_L"
                        ,"BrowsU_C_R"
                        ,"BrowsU_L" 
                        ,"BrowsU_R"
                        ,"BrowsSqueeze_L"
                        ,"BrowsSqueeze_R"
                        ,"JawOpen"
                        ,"LipsTogether" 
                        ,"JawChew"
                        ,"JawLeft"
                        ,"JawRight" 
                        ,"JawFwd" 
                        ,"JawBackward" 
                        ,"LipsUpperUp_L" 
                        ,"LipsUpperUp_R" 
                        ,"LipsLowerDown_L" 
                        ,"LipsLowerDown_R" 
                        ,"LipsUpperClose" 
                        ,"LipsLowerClose" 
                        ,"LipsLowerOpen" 
                        ,"LipsUpperOpen" 
                        ,"MouthSharpCornerPull_L" 
                        ,"MouthSharpCornerPull_R" 
                        ,"MouthSmile_L" 
                        ,"MouthSmile_R" 
                        ,"MouthDimple_L" 
                        ,"MouthDimple_R" 
                        ,"LipsStretch_L" 
                        ,"LipsStretch_R" 
                        ,"MouthFrown_L" 
                        ,"MouthFrown_R" 
                        ,"MouthPress_L" 
                        ,"MouthPress_R" 
                        ,"LipsPucker_L" 
                        ,"LipsPucker_R" 
                        ,"LipsFunnel_L" 
                        ,"LipsFunnel_R" 
                        ,"LipsTowards_L"
                        ,"LipsTowards_R"
                        ,"MouthLeft" 
                        ,"MouthRight"
                        ,"MouthUp" 
                        ,"MouthDown" 
                        ,"ChinLowerRaise" 
                        ,"ChinUpperRaise" 
                        ,"Sneer_L" 
                        ,"Sneer_R" 
                        ,"NostrilDepress_L" 
                        ,"NostrilDepress_R" 
                        ,"NostrilContractor"
                        ,"NostrilDilator" 
                        ,"Puff_L" 
                        ,"Puff_R" 
                        ,"Suck" 
                        ,"CheekSquint_L"
                        ,"LipsFunnel"
                        ,"BrowsU_C"
                        ,"LipsLowerDown"
                        ,"LipsPucker"
                        ,"LipsUpperUp"
                        ,"Puff"
                        ,"Sneer"]
        
        
        for mmt in matchMotion:
        
            
        
            self.addStringAttr( obj = infoMatch_bridge , attrName = mmt , textinput = '@xxx#tx#1#ty#2#tz#4'  , edit = 0 )
            
            self.addAttrs( objname=[infoMatch_value_bridge],attrname= mmt ,dv=0,key=1)
        
        
        
        
    def getTextInfo(self,FieldText = ''):
        objInfo = []
        text = FieldText
        textSplit = text.split(' ')
        for t in textSplit:
            if ' ' in t:
                pass
            elif t == '':
                pass
            else:
                objInfo.append(t)
        return objInfo
        
        
            